typedef struct ListNode ListNode;
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB)
{
    ListNode* ptailA = headA, *ptailB = headB;
    int lenA = 1, lenB = 1;

    //先判断有没有相交节点
    while(ptailA->next)
    {
        ptailA = ptailA->next;
        lenA++;
    }
    while(ptailB->next)
    {
        ptailB = ptailB->next;
        lenB++;
    }
    if(ptailA != ptailB)
    {
        return NULL;
    }

    //假设法
    ListNode* longlist = headA, *shortlist = headB;
    if(lenA < lenB)
    {
        longlist = headB;
        shortlist = headA;
    }
    int k = abs(lenA - lenB);

    //先让长链表走k步
    while(k--)
    {
        longlist = longlist->next;
    }
    //同时走
    while(longlist != shortlist)
    {
        longlist = longlist->next;
        shortlist = shortlist->next;
    }
    return longlist;
}